//
//  DJTitleButton.m
//  WeiboDemo
//
//  Created by Bworm on 15/1/29.
//  Copyright (c) 2015年 Bworm. All rights reserved.
//

#import "DJTitleButton.h"

@implementation DJTitleButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [self setBackgroundImage:[UIImage imageNamed:@"navigationbar_title_highlighted"] forState:UIControlStateHighlighted];
    // 图片居中
    self.imageView.contentMode = UIViewContentModeCenter;
    // 标题文字居中
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    // 将图片跟文字的x值互换
    self.titleLabel.x = self.imageView.x;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) + 5;
}




@end
